import type * as T from './type'
import http from '@/utils/http'
import type {EnterpriseDto} from "./type";
import type {LabelValueState} from "@/types/global";
// @ts-ignore
export type * from './type'

const BASE_URL = '/business/mch/enterprise'
/** @desc 查询加盟商列表 */
export function listEnterprise(query: T.EnterpriseQuery) {
  return http.get<PageRes<T.EnterprisePageQuery[]>>(`${BASE_URL}/page`, query)
}


/** @desc 根下拉框選擇加盟商集合 */
export function getSelectEnterprises() {
  return http.get<LabelValueState[]>(`${BASE_URL}/getSelectEnterpriseList`)
}

/** @desc 根據單元編號查询加盟商集合 */
export function getByUnitIdEnterprises(query: any) {
  return http.get<EnterpriseDto[]>(`${BASE_URL}/list`,query)
}


/** @desc 查询加盟商详情 */
export function getEnterprise(id: string) {
  return http.get<T.EnterpriseDto>(`${BASE_URL}/getData/${id}`)
}


/** @desc 查询加盟商详情 */
export function getEnterpriseDetail() {
  return http.get<T.EnterpriseDto>(`${BASE_URL}/getDetail`)
}


/** @desc 新增加盟商 */
export function addEnterprise(data: any) {
  return http.post(`${BASE_URL}/createComm`, data)
}

/** @desc 修改加盟商 */
export function updateEnterprise(data: any) {
  return http.post(`${BASE_URL}/modifyComm`, data)
}

/** @desc 删除加盟商 */
export function deleteEnterprise(ids: string | Array<string>) {
  return http.del(`${BASE_URL}/delete/${ids}`)
}


/** @desc 重置密码 */
export function resetEnterprisePwd(data: any) {
  return http.post(`${BASE_URL}/resetPwd`, data)
}

